library(Seurat)
library(SeuratDisk)
library(reticulate)
library(scrubletR)
library(ggplot2)
library(patchwork)
library(dplyr)
library(data.table)
library(clustree)
library(reshape2)
library(tidyr)
library(gridExtra)
library(stringr)
library(plyr)
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_integration_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/xgboost/xgboost_train.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/xgboost/plottingFxns.R")

obj.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/opossum_v1_gabaergic_processed.rds")
obj.opossum.gabaergic$species <- "Opossum"
subclass.markers.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/marker_genes/GABAergic/markerdict_subclass.rds")
markers.opossum.gabaergic <- readRDS("E:/Transcriptomics_V1/Opossum/seurat/marker_genes/GABAergic/markerdict_types.rds")
obj.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/mouse_v1_P38_gabaergic_processed.rds")
obj.mouse.gabaergic.P38$species <- "Mouse"
subclass.markers.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/marker_genes/GABAergic/P38/markerdict_subclass.rds")
markers.mouse.gabaergic.P38 <- readRDS("E:/Transcriptomics_V1/Mouse/seurat/marker_genes/GABAergic/P38/markerdict_types.rds")

objs <- list(obj.opossum.gabaergic, obj.mouse.gabaergic.P38)
subclass.markers <- list(subclass.markers.opossum.gabaergic, subclass.markers.mouse.gabaergic.P38)
type.markers <- list(markers.opossum.gabaergic, markers.mouse.gabaergic.P38)
sample.names <- list("OpossumV1", "MouseV1-P38")

subclasses <- c("Pvalb", "Sst", "Vip", "Lamp5", "Frem1", "Stac")

# pre-integration subclass comparison (DE genes)
for (pc in c(T, F)) {
  p <- PlotSubclassDEIntersection(subclass.markers[[1]], subclass.markers[[2]], 
                                  rownames(objs[[1]]), rownames(objs[[2]]),
                                  sample.names[[1]], sample.names[[2]],
                                  subclasses, 0.2, "E:/Transcriptomics_V1/Integration/Opossum_Mouse/subclass_markers/", percentage = pc)
  print(p)
}
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer range

# pre-integration type comparison (DE genes)
for (pc in c(T, F)) {
  for (sbcl in subclasses) {
    if (sbcl %in% names(type.markers[[1]]) & sbcl %in% names(type.markers[[2]])) {
      p <- PlotIdentDEIntersection(type.markers[[1]], type.markers[[2]],
                                   rownames(objs[[1]]), rownames(objs[[2]]),
                                   sample.names[[1]], sample.names[[2]],
                                   sbcl, sbcl, "type", "type", 0.2, percentage = pc)
      print(p)
    }
  }
}


sbcl_conf_plots <- PlotSubclassCrossConfusionMatrices(objs[[1]], objs[[2]], 
                                                      sample.names[[1]], sample.names[[2]], 
                                                      assay = "SCT",
                                                      subclasses, n_iters = 10, all.genes = FALSE, upsample = TRUE)
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: package ‘xgboost’ was built under R version 4.3.1
Attaching package: ‘xgboost’

The following object is masked from ‘package:dplyr’:

    slice

Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer range


print(sbcl_conf_plots[[1]])

print(sbcl_conf_plots[[2]])


subclass.labels <- c("Pvalb", "Sst", "Vip")
ident.labels <- c("type")

idnt_conf_plots <- PlotIdentCrossConfusionMatrices(objs[[1]], objs[[2]], 
                                                   sample.names[[1]], sample.names[[2]], 
                                                   assay = "SCT",
                                                   subclass.labels, ident.labels, n_iters = 10, 
                                                   ident.genes = TRUE, all.genes = FALSE, upsample = TRUE)
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."


for (sbcl in subclass.labels) {
  for (id in ident.labels) {
    print(idnt_conf_plots[[sbcl]][[id]][["avg1"]])
    print(idnt_conf_plots[[sbcl]][[id]][["avg2"]])
  }
}


obj.integrated <- IntegrateObjects(objs[[1]], objs[[2]], resolutions = c(1, 2), nfeatures = 3000, subsample = TRUE)

  |                                                  | 0 % ~calculating  
  |+++++++++++++++++++++++++                         | 50% ~01s          
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s  
Finding all pairwise anchors

  |                                                  | 0 % ~calculating  
Running CCA
Merging objects
Finding neighborhoods
Finding anchors
    Found 4357 anchors
Filtering anchors
    Retained 3444 anchors

  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=19s  
sct.model: model1
Setting min_variance based on median UMI:  0.04
Calculating residuals of type pearson for 6513 genes

  |                                                                                                                                                                                                 
  |                                                                                                                                                                                           |   0%
  |                                                                                                                                                                                                 
  |=======                                                                                                                                                                                    |   4%
  |                                                                                                                                                                                                 
  |==============                                                                                                                                                                             |   8%
  |                                                                                                                                                                                                 
  |======================                                                                                                                                                                     |  12%
  |                                                                                                                                                                                                 
  |=============================                                                                                                                                                              |  15%
  |                                                                                                                                                                                                 
  |====================================                                                                                                                                                       |  19%
  |                                                                                                                                                                                                 
  |===========================================                                                                                                                                                |  23%
  |                                                                                                                                                                                                 
  |==================================================                                                                                                                                         |  27%
  |                                                                                                                                                                                                 
  |==========================================================                                                                                                                                 |  31%
  |                                                                                                                                                                                                 
  |=================================================================                                                                                                                          |  35%
  |                                                                                                                                                                                                 
  |========================================================================                                                                                                                   |  38%
  |                                                                                                                                                                                                 
  |===============================================================================                                                                                                            |  42%
  |                                                                                                                                                                                                 
  |======================================================================================                                                                                                     |  46%
  |                                                                                                                                                                                                 
  |==============================================================================================                                                                                             |  50%
  |                                                                                                                                                                                                 
  |=====================================================================================================                                                                                      |  54%
  |                                                                                                                                                                                                 
  |============================================================================================================                                                                               |  58%
  |                                                                                                                                                                                                 
  |===================================================================================================================                                                                        |  62%
  |                                                                                                                                                                                                 
  |==========================================================================================================================                                                                 |  65%
  |                                                                                                                                                                                                 
  |=================================================================================================================================                                                          |  69%
  |                                                                                                                                                                                                 
  |=========================================================================================================================================                                                  |  73%
  |                                                                                                                                                                                                 
  |================================================================================================================================================                                           |  77%
  |                                                                                                                                                                                                 
  |=======================================================================================================================================================                                    |  81%
  |                                                                                                                                                                                                 
  |==============================================================================================================================================================                             |  85%
  |                                                                                                                                                                                                 
  |=====================================================================================================================================================================                      |  88%
  |                                                                                                                                                                                                 
  |=============================================================================================================================================================================              |  92%
  |                                                                                                                                                                                                 
  |====================================================================================================================================================================================       |  96%
  |                                                                                                                                                                                                 
  |===========================================================================================================================================================================================| 100%
sct.model: model1
Setting min_variance based on median UMI:  0.04
Calculating residuals of type pearson for 6513 genes

  |                                                                                                                                                                                                 
  |                                                                                                                                                                                           |   0%
  |                                                                                                                                                                                                 
  |=======                                                                                                                                                                                    |   4%
  |                                                                                                                                                                                                 
  |==============                                                                                                                                                                             |   8%
  |                                                                                                                                                                                                 
  |======================                                                                                                                                                                     |  12%
  |                                                                                                                                                                                                 
  |=============================                                                                                                                                                              |  15%
  |                                                                                                                                                                                                 
  |====================================                                                                                                                                                       |  19%
  |                                                                                                                                                                                                 
  |===========================================                                                                                                                                                |  23%
  |                                                                                                                                                                                                 
  |==================================================                                                                                                                                         |  27%
  |                                                                                                                                                                                                 
  |==========================================================                                                                                                                                 |  31%
  |                                                                                                                                                                                                 
  |=================================================================                                                                                                                          |  35%
  |                                                                                                                                                                                                 
  |========================================================================                                                                                                                   |  38%
  |                                                                                                                                                                                                 
  |===============================================================================                                                                                                            |  42%
  |                                                                                                                                                                                                 
  |======================================================================================                                                                                                     |  46%
  |                                                                                                                                                                                                 
  |==============================================================================================                                                                                             |  50%
  |                                                                                                                                                                                                 
  |=====================================================================================================                                                                                      |  54%
  |                                                                                                                                                                                                 
  |============================================================================================================                                                                               |  58%
  |                                                                                                                                                                                                 
  |===================================================================================================================                                                                        |  62%
  |                                                                                                                                                                                                 
  |==========================================================================================================================                                                                 |  65%
  |                                                                                                                                                                                                 
  |=================================================================================================================================                                                          |  69%
  |                                                                                                                                                                                                 
  |=========================================================================================================================================                                                  |  73%
  |                                                                                                                                                                                                 
  |================================================================================================================================================                                           |  77%
  |                                                                                                                                                                                                 
  |=======================================================================================================================================================                                    |  81%
  |                                                                                                                                                                                                 
  |==============================================================================================================================================================                             |  85%
  |                                                                                                                                                                                                 
  |=====================================================================================================================================================================                      |  88%
  |                                                                                                                                                                                                 
  |=============================================================================================================================================================================              |  92%
  |                                                                                                                                                                                                 
  |====================================================================================================================================================================================       |  96%
  |                                                                                                                                                                                                 
  |===========================================================================================================================================================================================| 100%
Merging dataset 2 into 1
Extracting anchors for merged samples
Finding integration vectors
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Integrating data
Warning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer range

PlotIntegration(obj.integrated, "species", c("integrated_snn_res.1", "integrated_snn_res.2"), subclasses)


objs.i <- SplitObject(obj.integrated, split.by = "species")

sbcl_conf_plots_i <- PlotSubclassCrossConfusionMatrices(objs.i[[1]], objs.i[[2]], 
                                                        sample.names[[1]], sample.names[[2]], 
                                                        assay = "integrated",
                                                        subclasses, n_iters = 10, all.genes = FALSE, upsample = TRUE)
Warning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer rangeWarning: NAs introduced by coercion to integer range


print(sbcl_conf_plots_i[[1]])

print(sbcl_conf_plots_i[[2]])


subclass.labels <- c("Pvalb", "Sst", "Vip")
ident.labels <- c("type")

idnt_conf_plots_i <- PlotIdentCrossConfusionMatrices(objs.i[[1]], objs.i[[2]], 
                                                     sample.names[[1]], sample.names[[2]], 
                                                     assay = "integrated",
                                                     subclass.labels, ident.labels, n_iters = 10, 
                                                     ident.genes = TRUE, all.genes = FALSE, upsample = TRUE)
[1] "Using IntegrationFeatures from the Ident level..."
Warning: Not all features provided are in this Assay object, removing the following feature(s): Ush1c, Uaca, Ntsr1, Cdh16, Aldh1a3, Ltf, Cenpf, Trp63, Tdrd1, Ptpn20, Ndc80, Dlk1, Slc5a11, Vwa7, Commd1, Zhx1, Tnnt2, Ribc2, Fam178b, Cpz, Frem3, Shcbp1, Rnasek, Satl1, Pik3r5, Cnga3, Ghrh, Abcb6, Pdlim4, Bco1, Nr0b1, Bnc1, Tmem42, Cd4, Ebi3, Ptgr1, Tmem182, Cpvl, 1810020O05Rik, Fbln7, Kdelr3, Mael, Hhip, Obscn, Xrra1, Gm6657, Pkd1l1, Gadl1, Azgp1, Aspg, Tor4a, Ano7, Cyp27a1, Nme3, Tktl2, Rnase1, Tcea3, Tinag, Pudp, Chkb, Cel, Glipr2, Phf19, Rnf139, Ing4, Zfp488, Pbp2, Fermt1, Ppt2, Cd5, Dscc1, Mylk4, Pdzd9, Prnp, Ikzf1, Pik3ap1, Tm4sf20, Wnt9b, Alox15, Traf3ip3, Sec31b, Tcf7, Cbx6, Tpte, Catsper4, Klk11, Ccdc158, Zc3h11a, Lypla1Warning: Not all features provided are in this Assay object, removing the following feature(s): Ush1c, Uaca, Ntsr1, Cdh16, Aldh1a3, Ltf, Cenpf, Trp63, Tdrd1, Ptpn20, Ndc80, Dlk1, Slc5a11, Vwa7, Commd1, Zhx1, Tnnt2, Ribc2, Fam178b, Cpz, Frem3, Shcbp1, Rnasek, Satl1, Pik3r5, Cnga3, Ghrh, Abcb6, Pdlim4, Bco1, Nr0b1, Bnc1, Tmem42, Cd4, Ebi3, Ptgr1, Tmem182, Cpvl, 1810020O05Rik, Fbln7, Kdelr3, Mael, Hhip, Obscn, Xrra1, Gm6657, Pkd1l1, Gadl1, Azgp1, Aspg, Tor4a, Ano7, Cyp27a1, Nme3, Tktl2, Rnase1, Tcea3, Tinag, Pudp, Chkb, Cel, Glipr2, Phf19, Rnf139, Ing4, Zfp488, Pbp2, Fermt1, Ppt2, Cd5, Dscc1, Mylk4, Pdzd9, Prnp, Ikzf1, Pik3ap1, Tm4sf20, Wnt9b, Alox15, Traf3ip3, Sec31b, Tcf7, Cbx6, Tpte, Catsper4, Klk11, Ccdc158, Zc3h11a, Lypla1
[1] "Using IntegrationFeatures from the Ident level..."
[1] "Using IntegrationFeatures from the Ident level..."


for (sbcl in subclass.labels) {
  for (id in ident.labels) {
    print(idnt_conf_plots_i[[sbcl]][[id]][["avg1"]])
    print(idnt_conf_plots_i[[sbcl]][[id]][["avg2"]])
  }
}


objs.m <- MapObjects(objs.i[[1]], objs.i[[2]], c("subclass", "type"), assay = "integrated")

source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_functions.R")
source("C:/Ryan/GitHub/trachtenberg-lab/transcriptomics/tools/seurat_integration_functions.R")
PlotMapping(objs.m, ident.order = subcl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bmVzKQ0KZm9yIChwYyBpbiBjKFQsIEYpKSB7DQogIGZvciAoc2JjbCBpbiBzdWJjbGFzc2VzKSB7DQogICAgaWYgKHNiY2wgJWluJSBuYW1lcyh0eXBlLm1hcmtlcnNbWzFdXSkgJiBzYmNsICVpbiUgbmFtZXModHlwZS5tYXJrZXJzW1syXV0pKSB7DQogICAgICBwIDwtIFBsb3RJZGVudERFSW50ZXJzZWN0aW9uKHR5cGUubWFya2Vyc1tbMV1dLCB0eXBlLm1hcmtlcnNbWzJdXSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm93bmFtZXMob2Jqc1tbMV1dKSwgcm93bmFtZXMob2Jqc1tbMl1dKSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxlLm5hbWVzW1sxXV0sIHNhbXBsZS5uYW1lc1tbMl1dLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYmNsLCBzYmNsLCAidHlwZSIsICJ0eXBlIiwgMC4yLCBwZXJjZW50YWdlID0gcGMpDQogICAgICBwcmludChwKQ0KICAgIH0NCiAgfQ0KfQ0KDQpgYGANCg0KDQpgYGB7ciwgZmlnLndpZHRoPTE1LCBmaWcuaGVpZ2h0PTZ9DQoNCnNiY2xfY29uZl9wbG90cyA8LSBQbG90U3ViY2xhc3NDcm9zc0NvbmZ1c2lvbk1hdHJpY2VzKG9ianNbWzFdXSwgb2Jqc1tbMl1dLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsZS5uYW1lc1tbMV1dLCBzYW1wbGUubmFtZXNbWzJdXSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3NheSA9ICJTQ1QiLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViY2xhc3Nlcywgbl9pdGVycyA9IDEwL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oNCnByaW50KHNiY2xfY29uZl9wbG90c19pW1sxXV0pDQpwcmludChzYmNsX2NvbmZfcGxvdHNfaVtbMl1dKQ0KDQpgYGANCg0KDQpgYGB7ciwgZmlnLndpZHRoPTE1LCBmaWcuaGVpZ2h0PTZ9DQoNCnN1YmNsYXNzLmxhYmVscyA8LSBjKCJQdmFsYiIsICJTc3QiLCAiVmlwIikNCmlkZW50LmxhYmVscyA8LSBjKCJ0eXBlIikNCg0KaWRudF9jb25mX3Bsb3RzX2kgPC0gUGxvdElkZW50Q3Jvc3NDb25mdXNpb25NYXRyaWNlcyhvYmpzLmlbWzFdXSwgb2Jqcy5pW1syXV0sIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzYW1wbGUubmFtZXNbWzFdXSwgc2FtcGxlLm5hbWVzW1syXV0sIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3NheSA9ICJpbnRlZ3JhdGVkIiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViY2xhc3MubGFiZWxzLCBpZGVudC5sYWJlbHMsIG5faXRlcnMgPSAxMCwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkZW50LmdlbmVzID0gVFJVRSwgYWxsLmdlbmVzID0gRkFMU0UsIHVwc2FtcGxlID0gVFJVRSkNCg0KYGBgDQoNCg0KYGBge3J9DQoNCmZvciAoc2JjbCBpbiBzdWJjbGFzcy5sYWJlbHMpIHsNCiAgZm9yIChpZCBpbiBpZGVudC5sYWJlbHMpIHsNCiAgICBwcmludChpZG50X2NvbmZfcGxvdHNfaVtbc2JjbF1dW1tpZF1dW1siYXZnMSJdXSkNCiAgICBwcmludChpZG50X2NvbmZfcGxvdHNfaVtbc2JjbF1dW1tpZF1dW1siYXZnMiJdXSkNCiAgfQ0KfQ0KDQpgYGANCg0KDQpgYGB7cn0NCg0Kb2Jqcy5tIDwtIE1hcE9iamVjdHMob2Jqcy5pW1sxXV0sIG9ianMuaVtbMl1dLCBjKCJzdWJjbGFzcyIsICJ0eXBlIiksIGFzc2F5ID0gImludGVncmF0ZWQiKQ0KDQpgYGANCg0KDQpgYGB7cn0NCg0KUGxvdE1hcHBpbmcob2Jqcy5tLCBpZGVudC5vcmRlciA9IHN1YmNsYXNzZXMpDQoNCmBgYA0KDQo=